package com.clarence.dada.modular.system.resource.entity.req;


import com.clarence.dada.core.base.BaseReq;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;

/**
 * 资源请求封装
 *
 * @author GD
 * @since 2019-09-10
 */
@Data
@Schema(title = "系统资源请求实例")
@EqualsAndHashCode(callSuper = true)
public class SysResourceReq extends BaseReq {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 资源id
     */
    @Schema(title = "资源id", example = "1")
    @NotNull(message = "资源编码为空", groups = {edit.class, delete.class, detail.class})
    private Long resourceId;

    /**
     * 应用编码
     */
    @Schema(title = "应用编码", example = "user")
    @NotBlank(message = "应用编码为空", groups = {add.class, edit.class})
    private String appCode;

    /**
     * 资源编码
     */
    @Schema(title = "资源编码", example = "userCode")
    @NotBlank(message = "资源编码为空", groups = {add.class, edit.class})
    private String resourceCode;

    /**
     * 资源名称
     */
    @Schema(title = "资源名称", example = "用户添加")
    @NotBlank(message = "资源名称为空", groups = {add.class, edit.class})
    private String resourceName;

    /**
     * 类名称
     */
    @Schema(title = "类名称", example = "用户")
    @NotBlank(message = "类名称为空", groups = {add.class, edit.class})
    private String className;

    /**
     * 方法名称
     */
    @Schema(title = "方法名称", example = "添加")
    @NotBlank(message = "方法名称为空", groups = {add.class, edit.class})
    private String methodName;

    /**
     * 资源模块编码
     */
    @Schema(title = "资源模块编码", example = "user")
    @NotBlank(message = "资源模块编码为空", groups = {add.class, edit.class})
    private String modularCode;

    /**
     * 资源模块名称
     */
    @Schema(title = "资源模块名称", example = "用户")
    @NotBlank(message = "资源模块名称为空", groups = {add.class, edit.class})
    private String modularName;

    /**
     * 是否是视图类型：Y-是，N-否
     * 如果是视图类型，url需要以 '/view' 开头，
     * 视图类型的接口会渲染出html界面，而不是json数据，
     * 视图层一般会在前后端不分离项目出现
     */
    @Schema(title = "是否是视图类型", example = "Y")
    @NotBlank(message = "是否是视图类型为空", groups = {add.class, edit.class})
    private String viewFlag;

    /**
     * 资源url
     */
    @Schema(title = "资源url", example = "/system/user/add")
    @NotBlank(message = "资源url为空", groups = {add.class, edit.class})
    private String url;

    /**
     * http请求方法
     */
    @Schema(title = "http请求方法", example = "GET")
    @NotBlank(message = "http请求方法为空", groups = {add.class, edit.class})
    private String httpMethod;

    /**
     * 是否需要登录：Y-是，N-否
     */
    @Schema(title = "是否需要登录：Y-是，N-否", example = "Y")
    @NotBlank(message = "是否需要登录为空", groups = {add.class, edit.class})
    private String requiredLoginFlag;

    /**
     * 是否需要鉴权：Y-是，N-否
     */
    @Schema(title = "是否需要鉴权：Y-是，N-否", example = "Y")
    @NotBlank(message = "是否需要鉴权为空", groups = {add.class, edit.class})
    private String requiredPermissionFlag;

    /**
     * 接口参数的字段描述
     * <p>
     * json形式存储
     */
    @Schema(title = "接口参数的字段描述", example = "参数字段描述")
    private String paramFieldDescriptions;

    /**
     * 接口返回结果的字段描述
     * <p>
     * json形式存储
     */
    @Schema(title = "接口返回结果的字段描述", example = "返回字段描述")
    private String responseFieldDescriptions;

}
